import { defHttp } from '/@/utils/http/axios';
import type { Result } from '/#/axios';

enum Api {
  ADMIN_SUBJECT_PREFIX = '/admin/subject',
  SUBJECT_LIST = '/getSubject',
  SUBJECT_DELETE = '/deleteSubjectById',
  SUBJECT_ADD = '/addSubject',
  TEACHER_IS_NAME_EXISTS = '/isNameExists',
  TEACHER_INFO_BY_ID = '/getTeacherInfoBYId',
  TEACHER_UPDATE = '/updateTeacher',
  TEACHER_DELETE_BATH = '/deleteTeacherByIds',
}
export const getSubject = () =>
  defHttp.get<Result>({
    url: `${Api.ADMIN_SUBJECT_PREFIX}${Api.SUBJECT_LIST}`,
    headers: {
      ignoreCancelToken: true,
    },
  });

export const addClassification = (data: any) =>
  defHttp.post<Result>(
    {
      url: `${Api.ADMIN_SUBJECT_PREFIX}${Api.SUBJECT_ADD}`,
      data,
      headers: {
        ignoreCancelToken: true,
      },
    },
    {
      successMessageMode: 'message',
    },
  );

export const deleteSubjectApi = (params: string) =>
  defHttp.delete<Result>(
    {
      url: `${Api.ADMIN_SUBJECT_PREFIX}${Api.SUBJECT_DELETE}/${params}`,
      headers: {
        ignoreCancelToken: true,
      },
    },
    {
      successMessageMode: 'message',
    },
  );
